package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.webadmin.upms.model.SysUser;
import com.train.webadmin.app.model.constant.Sex;
import com.train.webadmin.app.model.constant.Nation;
import com.train.webadmin.app.model.constant.Education;
import com.train.webadmin.app.model.constant.Status;
import com.train.common.core.util.MyCommonUtil;
import com.train.common.core.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 学生列表实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "student_info")
public class StudentInfo {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 班级id。
     */
    @TableField(value = "class_id")
    private Long classId;

    /**
     * 姓名。
     */
    @TableField(value = "name")
    private String name;

    /**
     * 手机号码。
     */
    @TableField(value = "phone")
    private String phone;

    /**
     * 2 男 1女。
     */
    @TableField(value = "sex")
    private Integer sex;

    /**
     * 身份证号码。
     */
    @TableField(value = "identity_card")
    private String identityCard;

    /**
     * 民族。
     */
    @TableField(value = "nation")
    private String nation;

    /**
     * 毕业学校。
     */
    @TableField(value = "schoolTag")
    private String schooltag;

    /**
     * 学历。
     */
    @TableField(value = "education")
    private String education;

    /**
     * 教学课。
     */
    @TableField(value = "teach_subjects")
    private String teachSubjects;

    /**
     * 职称。
     */
    @TableField(value = "professional_title")
    private String professionalTitle;

    /**
     * 单位名称。
     */
    @TableField(value = "company_name")
    private String companyName;

    /**
     * 出生年月。
     */
    @TableField(value = "date_of_birth")
    private String dateOfBirth;

    /**
     * 单位学校id。
     */
    @TableField(value = "school_id")
    private Long schoolId;

    /**
     * 籍贯。
     */
    @TableField(value = "native_place")
    private String nativePlace;

    /**
     * 党派。
     */
    @TableField(value = "party_groupings")
    private String partyGroupings;

    /**
     * 职务。
     */
    @TableField(value = "job_title")
    private String jobTitle;

    /**
     * 任职时间。
     */
    @TableField(value = "job_time")
    private Date jobTime;

    /**
     * 进修编号。
     */
    @TableField(value = "refresher_course_code")
    private String refresherCourseCode;

    /**
     * 照片。
     */
    @TableField(value = "photograph")
    private String photograph;

    /**
     * 创造时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 修改时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 修改用户id。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 创建用户id。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 登录用户id。
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * 审核标记。
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * name / phone / identity_card / nation / schoolTag / education / date_of_birth / native_place / refresher_course_code LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    @RelationOneToOne(
            masterIdField = "userId",
            slaveModelClass = SysUser.class,
            slaveIdField = "userId")
    @TableField(exist = false)
    private SysUser sysUser;

    @RelationOneToOne(
            masterIdField = "classId",
            slaveModelClass = ClassInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private ClassInfo classInfo;

    @RelationOneToOne(
            masterIdField = "schoolId",
            slaveModelClass = SchoolInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private SchoolInfo schoolInfo;

    @RelationConstDict(
            masterIdField = "sex",
            constantDictClass = Sex.class)
    @TableField(exist = false)
    private Map<String, Object> sexDictMap;

    @RelationConstDict(
            masterIdField = "nation",
            constantDictClass = Nation.class)
    @TableField(exist = false)
    private Map<String, Object> nationDictMap;

    @RelationConstDict(
            masterIdField = "education",
            constantDictClass = Education.class)
    @TableField(exist = false)
    private Map<String, Object> educationDictMap;

    @RelationConstDict(
            masterIdField = "status",
            constantDictClass = Status.class)
    @TableField(exist = false)
    private Map<String, Object> statusDictMap;

    @TableField(exist = false)
    private String loginName;

    /**
     * 干部id。
     */
    @TableField(value = "officer_id")
    private Long officerId;

    @TableField(exist = false)
    private double score;

    @TableField(exist = false)
    private Integer certificateStatus;
}
